<?php

namespace App\Console\Commands;

use App\Models\User;
use Illuminate\Console\Command;

class GenerateToken extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'chat_api:generate-token';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '快速生成长期有效JWT的Token令牌';
   public function __construct() {
       parent::__construct();
   }

    public function handle()
    {
        $userId = $this->ask('请输入用户ID');
        $user = User::find($userId);
        if(!$user){
            return $this->error('用户没找到');
        }
        $ttl = 365 * 24 * 60 ;
        $this->info(auth('api')->setTTL($ttl)->login($user));
    }
}
